package data;

import com.EntityName;
import com.google.appengine.api.datastore.Entity;

public class CurrencyMaster extends AbstractData {
	private long id = -1;
	private String title;
	private String abreviation;
	private String symbol;

	public CurrencyMaster(){}
	
	public CurrencyMaster(long id)
	{
		this.id = id;
	}

	@Override
	public long getId() {
		return id;
	}

	public void setId(long id) {		
	}
	
	public String getTitle() {
		return title;
	}
	public void setTitle(String title) {
		this.title = title;
	}
	public String getAbreviation() {
		return abreviation;
	}
	public void setAbreviation(String abreviation) {
		this.abreviation = abreviation;
	}
	public String getSymbol() {
		return symbol;
	}
	public void setSymbol(String symbol) {
		this.symbol = symbol;
	}
	
	@Override
	public Entity getEntity() {
		Entity item;
		if(this.key == null)
			item = new Entity(EntityName.Currency);
		else
			item = new Entity(this.key);

		item.setProperty("title", this.title);
		item.setProperty("abreviation", this.abreviation);
		item.setProperty("symbol", this.symbol);
		return item;
	}
	@Override
	public void setEntity(Entity entity) {
		this.id = entity.getKey().getId();
		this.title = (String) entity.getProperty("title");
		this.abreviation = (String) entity.getProperty("abreviation");
		this.symbol = (String) entity.getProperty("symbol");
		this.key = entity.getKey();
	}
	
	public void LoadData() {
		if (this.id > -1) {
			Entity entity = LoadData(EntityName.Currency, this.id);
			setEntity(entity);
		}
	}
}
